package weaver.interfaces.hitech.duss.action.cgsq;

import com.sap.mw.jco.JCO;
import weaver.general.Util;
import weaver.interfaces.jjy.duss.util.SAPConnPool;

import java.util.HashMap;
import java.util.Map;

/**
 * @Title: ecology-9-demo
 * @Company: 泛微软件
 * @author: weaver.Dusongsong
 * @version: 1.0
 * @CreateDate: 2020-07-03
 * @Description: ${description}
 * @ModifyLog:
 **/

public class ZBPM_PO_LIST {
    public Map execute(String pono, String sapcode) {
        SAPConnPool SAPConn = new SAPConnPool();
        JCO.Client myConnection = SAPConn.getConnection();
        JCO.Function bapi = SAPConn.excuteBapi("ZBPM_PO_LIST");
        JCO.ParameterList input = bapi.getImportParameterList();//输入参数和结构处理
        JCO.ParameterList inputtable = bapi.getTableParameterList();//输入表的处理
        //输入参数
        input.setValue("4100000028", "I_EBELN");
        input.setValue("QCAF0001", "I_MATNR");

        //执行函数
        myConnection.execute(bapi);
        JCO.ParameterList out = bapi.getExportParameterList();//输出参数和结构处理
        JCO.ParameterList Table00 = bapi.getTableParameterList();//输出表的处理

        //返回处理结果以及日志
        Map<String,String> resultMap = new HashMap<>();
        String e_land1 = Util.null2String(out.getValue("E_LAND1"));
        String e_menge = Util.null2String(out.getValue("E_MENGE"));
        String e_netpr = Util.null2String(out.getValue("E_NETPR"));
        String e_waers = Util.null2String(out.getValue("E_WAERS"));
        resultMap.put("e_land1",e_land1);
        resultMap.put("e_menge",e_menge);
        resultMap.put("e_netpr",e_netpr);
        resultMap.put("e_waers",e_waers);
        System.out.println("SPA_COUNTS:" + resultMap.toString());
        //返回处理结果以及日志
        JCO.releaseClient(myConnection);
        return resultMap;
    }

    public static void main(String[] args) {
        ZBPM_PO_LIST po_list = new ZBPM_PO_LIST();
        po_list.execute("4100000028","QCAF0001");
    }
}
